<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="/css/index.css">
    <script src="/js/vue.js" type="text/javascript"></script>
    <script src="/js/axios.js" type="text/javascript"></script>
    <script src="/js/index.js"></script>
</head>

<body>
<div id="app">

    <div  th:include="common/common-nav::head"></div>

    <div class="container">

        <div style="width:90%;margin:0 auto;flex-direction: column;justify-content:space-between">

            <el-input style="margin-top: 20px" class="inp" type=""placeholder="账号" v-model="username"></el-input>

            <el-input placeholder="请输入密码" v-model="password" show-password></el-input>

            <div style="display:flex;justify-content: space-between;margin-top: 20px">
                <el-button class="btn_login" type="primary" @click="login()" >登录</el-button>
                <el-button class="btn_register" type="primary">
                    <a href="/goRegister">注册</a>
                </el-button>
            </div>

        </div>

    </div>
</div>
</body>
<script>
    new Vue({
        el:"#app",
        data(){
            return{
				username:"",
				password:"",
                searchTitle:"",
            }
        },
        methods:{
			//登录
            login(){
				let fd  = new FormData()
                let that = this
				fd.append("username",this.username)
				fd.append("password",this.password)
                axios.post('/doLogin',fd).then(
                    function(resp){
                        console.log(resp)
                        if(resp.data.action==null){
                            that.$notify.error({
                                title: '错误',
                                message: '账号或者密码错误'
                            });
                            return
                        }
                        sessionStorage.setItem("msg",resp.data.msg)
                        window.location.href = resp.data.action
                    }
                )
            },
            findByTitle:function(){
                if(this.searchTitle==null || this.searchTitle == ""){
                    this.$notify({
                        title: '搜索不能为空',
                        type: 'warning'
                    });
                    return
                }
                sessionStorage.setItem('searchTitle',this.searchTitle)
                window.location.href = "/"
            },
        }
    })
</script>
<style>
    *{
        margin:0;
        padding:0;
    }
    .container{
        width: 20%;
        height: 200px;
        margin: 10% auto;
        border-radius: 5px;
        background-color: white;
    }
    .btn_login{
        margin-right: 130px;
    }
    .inp{
        margin-bottom: 20px;
    }
    a{
        text-decoration: none;
        color: #FFFFFF;
    }
    body{
        height:100%;
        width: 100%;
        background-image: url("/img/1.jpeg");
        background-size: cover;
    }
    .el-menu--horizontal>.el-menu-item.is-active{
        border-bottom:none;
        color: #303133;
    }
</style>
</html>